package com.toKnow.model.vo;

import com.toKnow.model.entity.Source;
import com.toKnow.model.entity.Tag;
import com.toKnow.model.entity.Type;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class SourceVo {
    private String source_id;
    private String title;
    private String source_name;
    private Integer author_id;
    private String author_name;
    private String avatar;
    private Date upload_date;
    private String file;
    private String cover;
    private String digest;

    private Boolean is_free;
    private Double price;
    private Integer sales;
    private Integer download_times;
    private Integer like_times;
    private Integer collect_times;
    private Integer comment_times;
    private List<String> type=new ArrayList<>();
    private List<String> tag=new ArrayList<>();
    private Boolean is_like;
    private Boolean is_collect;
    private Boolean is_Buy;

    public SourceVo() {
    }

    @Override
    public String toString() {
        return "SourceVo{" +
            "source_id='" + source_id + '\'' +
            ", title='" + title + '\'' +
            ", source_name='" + source_name + '\'' +
            ", author_id=" + author_id +
            ", author_name='" + author_name + '\'' +
            ", avatar='" + avatar + '\'' +
            ", upload_date=" + upload_date +
            ", file='" + file + '\'' +
            ", cover='" + cover + '\'' +
            ", digest='" + digest + '\'' +
            ", is_free=" + is_free +
            ", price=" + price +
            ", sales=" + sales +
            ", download_times=" + download_times +
            ", like_times=" + like_times +
            ", collect_times=" + collect_times +
            ", comment_times=" + comment_times +
            ", type=" + type +
            ", tag=" + tag +
            ", is_like=" + is_like +
            ", is_collect=" + is_collect +
            ", is_Buy=" + is_Buy +
            '}';
    }

    public SourceVo(String source_id, String title, String source_name, Integer author_id, String author_name, String avatar, Date upload_date, String file, String cover, String digest, Boolean is_free, Double price, Integer sales, Integer download_times, Integer like_times, Integer collect_times, Integer comment_times, List<String> type, List<String> tag, Boolean is_like, Boolean is_collect, Boolean is_Buy) {
        this.source_id = source_id;
        this.title = title;
        this.source_name = source_name;
        this.author_id = author_id;
        this.author_name = author_name;
        this.avatar = avatar;
        this.upload_date = upload_date;
        this.file = file;
        this.cover = cover;
        this.digest = digest;
        this.is_free = is_free;
        this.price = price;
        this.sales = sales;
        this.download_times = download_times;
        this.like_times = like_times;
        this.collect_times = collect_times;
        this.comment_times = comment_times;
        this.type = type;
        this.tag = tag;
        this.is_like = is_like;
        this.is_collect = is_collect;
        this.is_Buy = is_Buy;
    }

    public String getSource_id() {
        return source_id;
    }

    public void setSource_id(String source_id) {
        this.source_id = source_id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getSource_name() {
        return source_name;
    }

    public void setSource_name(String source_name) {
        this.source_name = source_name;
    }

    public Integer getAuthor_id() {
        return author_id;
    }

    public void setAuthor_id(Integer author_id) {
        this.author_id = author_id;
    }

    public String getAuthor_name() {
        return author_name;
    }

    public void setAuthor_name(String author_name) {
        this.author_name = author_name;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public Date getUpload_date() {
        return upload_date;
    }

    public void setUpload_date(Date upload_date) {
        this.upload_date = upload_date;
    }

    public String getFile() {
        return file;
    }

    public void setFile(String file) {
        this.file = file;
    }

    public String getCover() {
        return cover;
    }

    public void setCover(String cover) {
        this.cover = cover;
    }

    public String getDigest() {
        return digest;
    }

    public void setDigest(String digest) {
        this.digest = digest;
    }

    public Boolean getIs_free() {
        return is_free;
    }

    public void setIs_free(Boolean is_free) {
        this.is_free = is_free;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public Integer getSales() {
        return sales;
    }

    public void setSales(Integer sales) {
        this.sales = sales;
    }

    public Integer getDownload_times() {
        return download_times;
    }

    public void setDownload_times(Integer download_times) {
        this.download_times = download_times;
    }

    public Integer getLike_times() {
        return like_times;
    }

    public void setLike_times(Integer like_times) {
        this.like_times = like_times;
    }

    public Integer getCollect_times() {
        return collect_times;
    }

    public void setCollect_times(Integer collect_times) {
        this.collect_times = collect_times;
    }

    public Integer getComment_times() {
        return comment_times;
    }

    public void setComment_times(Integer comment_times) {
        this.comment_times = comment_times;
    }

    public List<String> getType() {
        return type;
    }

    public void setType(List<String> type) {
        this.type = type;
    }

    public List<String> getTag() {
        return tag;
    }

    public void setTag(List<String> tag) {
        this.tag = tag;
    }

    public Boolean getIs_like() {
        return is_like;
    }

    public void setIs_like(Boolean is_like) {
        this.is_like = is_like;
    }

    public Boolean getIs_collect() {
        return is_collect;
    }

    public void setIs_collect(Boolean is_collect) {
        this.is_collect = is_collect;
    }

    public Boolean getIs_Buy() {
        return is_Buy;
    }

    public void setIs_Buy(Boolean is_Buy) {
        this.is_Buy = is_Buy;
    }

    public SourceVo(Source source){
        this.source_id = String.valueOf(source.getId());
        this.title = source.getTitle();
        this.source_name = source.getSourceName();
        this.author_id = source.getAuthorId();
        this.author_name = source.getAuthorName();
        this.upload_date = source.getPublishDate();
        this.file = source.getFile();
        this.cover = source.getCover();
        this.digest = source.getDigest();
        this.is_free = source.getCharged();
        this.price = source.getPrice();
        this.sales = source.getBuyNumber();
        this.download_times = source.getDownloadNumber();
        this.like_times = source.getLikeNumber();
        this.collect_times = source.getCollectNumber();
        this.comment_times = source.getCommentNumber();
        this.avatar=source.getAvatar();
        for (Tag tagi : source.getTagList()){
            tag.add(tagi.getName());
        }
        for (Type typei:source.getTypeList()) {
            type.add(typei.getName());
        }
    }
}
